package com.example.pearl.business.service.impl;

import com.example.pearl.business.service.UserService;
import com.example.pearl.common.entity.User;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    
    // 模拟数据库中的用户数据
    private static final Map<String, User> USER_MAP = new HashMap<>();
    
    static {
        // 初始化默认用户 admin/123456
        USER_MAP.put("admin", new User(1L, "admin", "123456"));
    }
    
    @Override
    public User findByUsername(String username) {
        return USER_MAP.get(username);
    }
    
    @Override
    public boolean verifyPassword(User user, String password) {
        if (user == null) {
            return false;
        }
        return user.getPassword().equals(password);
    }
}